package com.wl.application.config;

import com.wl.application.interceptor.LoginInterceptor;
import com.wl.application.interceptor.PowerInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author wl
 * @version 1.0
 * @date 2022/6/16
 * @description: 过滤器注册
 */
@Configuration
public class MyInterceptor implements WebMvcConfigurer {


    @Autowired
    private LoginInterceptor interceptor;

    @Autowired
    private PowerInterceptor powerInterceptor;



    //访问资源拦截器 注册顺序就是执行顺序
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //登录校验拦截器
        registry.addInterceptor(interceptor).addPathPatterns("/**")
                .excludePathPatterns("/login")
                .excludePathPatterns("/user/save/*")
                .excludePathPatterns("/user/checkName/*")
                .excludePathPatterns("/port")
                .order(1);

        //权限校验拦截器
        registry.addInterceptor(powerInterceptor).addPathPatterns("/**")
                .excludePathPatterns("/login")
                .excludePathPatterns("/user/save/*")
                .excludePathPatterns("/user/checkName/*")
                .excludePathPatterns("/port")
                .order(2);



    }
}
